package cn.afterturn.easypoi.word.parse.excel;

import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.word.entity.bookmark.ExportExecel.NormalParagraph;
import cn.afterturn.easypoi.word.entity.bookmark.ExportExecel.TablePara;

import java.io.File;
import java.util.List;

public class ExcelToListUtil {
    public static List<NormalParagraph> readExcelToList(String filePath,String savepath){
    //取第一个sheet
        ImportParams params = new ImportParams();
        params.setTitleRows(1);
        params.setHeadRows(1);
        params.setStartSheetIndex(0);
        params.setSheetNum(1);

        params.setNeedSave(true);
        params.setSaveUrl(savepath);
        List<NormalParagraph> resultNormal = ExcelImportUtil.importExcel(
                new File(filePath),
                NormalParagraph.class, params);
        return resultNormal;
    }
    public static List<TablePara> readExcelToListTablePara(String filePath, String savepath){
        //取第二个sheet。与第一个sheet的差别，主要是setStartSheetIndex
        ImportParams paramtable = new ImportParams();
        paramtable.setTitleRows(1);
        paramtable.setHeadRows(1);
        paramtable.setStartSheetIndex(1);

        paramtable.setNeedSave(true);
        paramtable.setSaveUrl(savepath);
        List<TablePara> resulttable = ExcelImportUtil.importExcel(
                new File(filePath),
                TablePara.class, paramtable);
        return resulttable;
    }
}
